<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <meta HTTP-EQUIV="Expires" CONTENT="0">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>箱号编码管理</title>
    <style type="text/css">
        @import "../dojo-release-1.5.0/dijit/themes/tundra/tundra.css";
        @import "../dojo-release-1.5.0/dojo/resources/dojo.css";
        @import "../dojo-release-1.5.0/dojox/grid/resources/tundraGrid.css";
    </style>
    <script type="text/javascript" src="../dojo-release-1.5.0/dojo/dojo.js" djConfig="parseOnLoad:true"></script>
    <script type="text/javascript" src="../framework/uiutil.js"></script>
    <script type="text/javascript" src="../framework/simpleCRUDUtil.js"></script>

    <script type="text/javascript">
        var SCU = new SimpleCrudUtil({
            c: "../bkgrd/saveOrUpdateBoxNumber.do",
            u: "../bkgrd/saveOrUpdateBoxNumber.do",
            r: "../bkgrd/getAllBoxNumber.do",
            d: "../bkgrd/deleteBoxNumber.do",
            grid: "grid",
            idName: "codeName",
            translateFun: function (item) {
                item["isCycleStr"] = item["isCycle"] ? "是" : "否";
                item["isAvailableStr"] = item["isAvailable"] ? "启用" : "停用";
                var toUsedRetrievedCodeStr = ""
                for (var i in item["retrievedCodeList"]) {
                    toUsedRetrievedCodeStr += (item["retrievedCodeList"][i] + "\r\n");
                }
                item["toUsedRetrievedCode"] = toUsedRetrievedCodeStr;
            }
        });

        dojo.addOnLoad(function () {
            SCU.R();
        });

        function refreshList() {
            SCU.R();
        }

        function saveOrUpdateBoxNumber() {
            var codeName = dojo.byId("codeName").value;
            var carvingsName = dojo.byId("carvingsName").value;
            var description = dojo.byId("description").value;
            var quantity = dojo.byId("quantity").value;
            var scheme = dojo.byId("scheme").value;
            var nowCode = dojo.byId("nowCode").value;
            var isCycle = D.getSingleCheckBoxCheckedInt("isCycle");
            var isAvailable = D.getSingleCheckBoxCheckedInt("isAvailable");

            /* 	if(codeName == ''){
                    alert("请至少输入编码名称");
                    return;
                } */
            if (codeName == '' || scheme == ''||quantity==''||nowCode=='') {
                alert("请输入相关参数");
                return;
            }
            var model = {
                codeName: codeName,
                carvingsName: carvingsName,
                description: description,
                scheme: scheme,
                quantity: quantity,
                nowCode: nowCode,
                isCycle: isCycle,
                isAvailable: isAvailable
            };
            /* 	var model = {codeName:codeName,description:description,scheme:scheme,nowCode:nowCode,
                        isCycle:isCycle,isAvailable:isAvailable}; */
            if (SCU.dupl(codeName)) {
                if (!confirm("参数已存在，是否确认更新？")) return;
                SCU.U(model);
            } else {
                SCU.C(model);
            }
        }

        //删除参数
        function deleteBoxNumber() {
            SCU.D();
        }

        //开始修改
        function startModifyBoxNumber() {
            var item = SCU.getSelectedItem();
            if (item == null) return;

            dojo.byId("codeName").value = item["codeName"];
            dojo.byId("carvingsName").value = item["carvingsName"];
            dojo.byId("description").value = item["description"];
            dojo.byId("quantity").value = item["quantity"];
            dojo.byId("scheme").value = item["scheme"];
            dojo.byId("nowCode").value = item["nowCode"];
            dijit.byId("isCycle").setChecked(item["isCycle"] != 0);
            dijit.byId("isAvailable").setChecked(item["isAvailable"] != 0);
        }


    </script>

    <style type="text/css">
        #grid {
            border: 1px solid #333;
            width: 80%;
            margin: 10px;
            height: 200px;
            font-size: 0.9em;
        }
    </style>
</head>
<body class="tundra">


新增&nbsp;箱号&nbsp;编码
<table width="100%">
    <tr>
        <td>编码名称</td>
        <td><input type="text" dojoType="dijit.form.TextBox" id="codeName" size="100" trim="true" value=""/></td>
    </tr>
    <tr>
        <td>镭雕机名称</td>
        <td><input type="text" dojoType="dijit.form.TextBox" id="carvingsName" size="100" trim="true" value=""/></td>
    </tr>
    <tr>
        <td>描述</td>
        <td><input type="text" dojoType="dijit.form.TextBox" id="description" size="100" trim="true" value=""/></td>
    </tr>
    <tr>
        <td>模式</td>
        <td><input type="text" dojoType="dijit.form.TextBox" id="scheme" size="100" trim="true" value=""
                   style="width: 400px"/></td>
    </tr>
    <tr>
        <td>每箱容量</td>
        <td><input type="text" dojoType="dijit.form.TextBox" id="quantity" size="100" trim="true" value=""/></td>
    </tr>
    <tr>
        <td>是否启用</td>
        <td><input dojoType="dijit.form.CheckBox" checked="true" id="isAvailable"/>同名编码规则只能启用1个
        </td>
    </tr>
    <tr>
        <td colspan="2">
            &nbsp;
            <p>
            箱号模式规则如下：<br/>
            1、静态符号直接写；<br/>
            2、范围符号格式$类型[起-值]，类型包括：16进制(H)，10进制(D)，小写字母(c)，大写字母(C)<br/>
            3、例如：$H[x-y]16进制符号，1-9-A-F；$D[0-9]10进制符号；$c[a-z]小写字母；$C[A-Z]大写字母<br/>
            4、例如ABC$H[0-F]$H[0-A]$H[0-F]12，可匹配ABCDA0123、ABCDA1123、ABCDA2123、ABCE00123等<br/>
            5、输入时最后四位十进制数字为箱号<br/>
            </p>

        </td>
    </tr>

    <tr>
        <td>起始箱号编码</td>
        <td><input type="text" dojoType="dijit.form.TextBox" id="nowCode" size="30" trim="true" value=""/></td>
    </tr>
    <tr>
        <td>循环使用</td>
        <td><input dojoType="dijit.form.CheckBox" id="isCycle"/>循环使用</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td colspan="2">
            <button dojoType="dijit.form.Button" id="query" onclick="saveOrUpdateBoxNumber()">保存参数</button>
            <button dojoType="dijit.form.Button" id="delete" onclick="deleteBoxNumber()">删除参数</button>
            <button dojoType="dijit.form.Button" id="modify" onclick="startModifyBoxNumber()">修改参数</button>
            <button dojoType="dijit.form.Button" id="refreshList" onclick="refreshList()">刷新</button>
        </td>
    </tr>
</table>
<p>&nbsp;</p>
<table dojoType="dojox.grid.DataGrid" id="grid"  autoWidth="true">
    <thead>
    <tr>
        <th field="codeName" width="100px">编码名</th>
        <th field="carvingsName" width="100px">镭雕机名称</th>
        <th field="description" width="200px">编码描述</th>
        <th field="scheme" width="300px">模式</th>
        <th field="nowCode" width="100px">箱号编码</th>
        <th field="count" width="100px">已完成数量</th>
        <th field="quantity" width="100px">每箱容量</th>
        <th field="caseCode" width="100px">箱号</th>
        <th field="toUsedRetrievedCode" width="100px">回收待用值</th>
        <th field="isCycleStr" width="100px">循环使用</th>
        <th field="isAvailableStr" width="100px">启用状态</th>
    </tr>
    </thead>
</table>

</body>
</html>